package com.app.community.mapper;

import com.app.community.model.entity.Question;
import org.apache.ibatis.annotations.*;

/**
 * 发布问题
 *  2020/10/10 11:44
 **/
@Mapper
public interface PublishMapper {

    @Select({"select * from question"})
    Question searchAll();

    /**
     * 发布问题,初始浏览数为1
     */
    @Insert({"Insert into question(question_id,title,article,creator,date,cover_pic,summary,browse_count) values (#{question_id},#{title},#{article},#{creator},#{date},#{coverPic},#{summary},1)"})
    void publishQuestion(@Param("question_id") Long questionId, @Param("title") String title, @Param("article") String article, @Param("creator") String creator, @Param("date") String date, @Param("coverPic") String coverPic, @Param("summary") String summary);


    @Results({
            @Result(column = "question_id", property = "questionId"),
            @Result(column = "cover_pic",property = "coverPic")
    })
    @Select({"select * from question where question_id = #{question_id}"})
    Question searchQuestionById(@Param("question_id") Long questionId);

}
